package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.BuildingListBean;
import com.sx.zongzhi.bean.BuildingSearchBean;
import com.sx.zongzhi.modle.CollectManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IBuildingView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/1/13.
 * 获取楼宇列表
 */
public class BuildingListPest {

    private IBuildingView buildingView;

    public BuildingListPest(IBuildingView buildingView) {
        this.buildingView=buildingView;
    }


    public void loadBuildingList(String organizationID, BuildingSearchBean searchBean, int page, int rows){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("builddatasSearchVo.organization.id", organizationID);
        if (searchBean!=null){
            map.put("builddatasSearchVo.buildingname", searchBean.getBuildingname());
            map.put("builddatasSearchVo.buildingaddress", searchBean.getBuildingaddress());
            map.put("builddatasSearchVo.owner", searchBean.getOwner());
            map.put("builddatasSearchVo.responsibleperson", searchBean.getResponsibleperson());
            map.put("builddatasSearchVo.phone", searchBean.getPhone());
            map.put("builddatasSearchVo.buildingstructuresId", searchBean.getBuildingstructuresId());
        }
        map.put("page",page);
        map.put("rows",rows);
        new CollectManager().loadBuildingList(map, new BaseCallBack<BaseResult<BuildingListBean>>() {
            @Override
            public void onSuccess(BaseResult<BuildingListBean> response) {
                buildingView.loadBuildingList(response.getData());
            }
            @Override
            public void onFailures(String message) {
                buildingView.showError(message);
            }
        });
    }


}
